package com.tjsinfo.tjsoa.addresslist.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tjsinfo.tjsoa.addresslist.bo.IAddressListUserBo;

public class CopyAddressListUserAction extends Action{
	private IAddressListUserBo listUserBo;
	public IAddressListUserBo getListUserBo() {
		return listUserBo;
	}
	public void setListUserBo(IAddressListUserBo listUserBo) {
		this.listUserBo = listUserBo;
	}
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		
		String moduleType = request.getParameter("moduleType");
		String type = request.getParameter("type");
		String copyid = request.getParameter("copyid");
		String copyids = request.getParameter("copyids");
		String copygroup = request.getParameter("copygroup");
		if ("move".equals(type)) {
			listUserBo.MoveListUser(copyid.substring(0, copyid.length()-1), copygroup);
		}else{
			String[] c = copyids.split(",");
			for (int i = 0; i < c.length; i++) {
				listUserBo.CopyListUser(c[i], copygroup);
			}
		}
		String returnString = "复	制	成	功!";
		request.setAttribute("moduleType", moduleType);
		request.setAttribute("first", "shi");
		request.setAttribute("type", type);
		
		if ("move".equals(type)) {
			returnString = "移	动	成	功!";
		}
		request.setAttribute("returnString", returnString);
		
		return mapping.findForward("ok");
	}
}
